package com.gotop.mapper.core.log.logger;

import com.gotop.mapper.core.log.publisher.UsualLogPublisher;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;

/**
 * @program: cem
 * @description:
 * @author: superfish
 * @create: 2020-12-28 15:11
 **/
@Slf4j
public class BaseLogger implements InitializingBean {

    @Value("${spring.application.name}")
    private String serviceId;

    public BaseLogger() {
    }

    public void info(String id, String data) {
        UsualLogPublisher.publishEvent("info", id, data);
    }

    public void debug(String id, String data) {
        UsualLogPublisher.publishEvent("debug", id, data);
    }

    public void warn(String id, String data) {
        UsualLogPublisher.publishEvent("warn", id, data);
    }

    public void error(String id, String data) {
        UsualLogPublisher.publishEvent("error", id, data);
    }

    public void afterPropertiesSet() throws Exception {
        log.info(this.serviceId + ": BladeLogger init success!");
    }
}
